/*
 * Debug.h
 *
 *  Created on: 2010-9-10
 *      Author: liuyi
 */

#ifndef DEBUG_H_
#define DEBUG_H_

#include <sys/time.h>

#include <string>
#include <iostream>

#include <cxcore.h>


class Timer {
public:

    /** return millisecond */
    static long calcTimeUsed(const Timer &start, const Timer &end) {
        return (end.m_time.tv_sec - start.m_time.tv_sec)*s_THOUSAND +
                (end.m_time.tv_usec - start.m_time.tv_usec) / s_THOUSAND;
    }

    Timer() {
        gettimeofday(&m_time, NULL);
    }

    ~Timer() {
    }

private:
    static const int s_THOUSAND = 1000;
    struct timeval m_time;

};


class Debug {
public:
    /** show the image and save it when press ctrl+s */
    static void showImage(const char * winName, const IplImage *image, int wait = 0);

    static void showManyImage(char *title, int nArgs, ...);

    static void mouseCallback(int event, int x, int y, int flags, void *param);

    static void trackbarCallback(int pos);

private:
    static const int s_RGB_CHANNAL = 3;

	static const int s_TRACKBAR_COUNT = 400;

    static const IplImage *s_originImage;

    static int s_trackbarPos;

    static bool s_blindWindowOpen;

    static void setBlindWindow(const char *winName, int x, int y);

    Debug(void);
    ~Debug(void);

};

#endif /* DEBUG_H_ */
